<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <body>
        <ui:composition template="./template.xhtml">
            <ui:define name="navigation">
                <ul>
                    <li><h:link value="#{msg.backToLogin}" outcome="index"/></li>
                </ul>
            </ui:define>
            <ui:define name="content">  
                
                    <h2>#{msg.register}</h2>
                    <p>#{msg.registerText}</p>
                        <h:form>


                        <h3>#{msg.loginData}</h3>
                        <div class="formblock">
                            <fieldset>
                                <div>
                                    <h:outputLabel class="Float" for="username" value="#{msg.username}" />
                                    <h:inputText label="username" value="#{registerController.newPlayer.username}" id="username">
                                        <f:validateRegex pattern="[A-Za-z]+"/>
                                    </h:inputText>                    
                                    <h:messages styleClass="error" for="username" showDetail="true" showSummary="false" />
                                </div>

                                <div>
                                    <h:outputLabel class="Float" for="password" value="#{msg.password}" /> 
                                    <h:inputSecret label="password" id="password" value="#{registerController.newPlayer.password}">
                                        <f:validateLength minimum="3"/>
                                        <f:validateRegex pattern="[A-Za-z0-9]*([A-Za-z][0-9]|[0-9][A-Za-z])[A-Za-z0-9]*"/>
                                    </h:inputSecret>
                                    <h:messages styleClass="error" for="password" showDetail="true" showSummary="false"/>
                                </div>
                            </fieldset>
                        </div>
                        <h:selectBooleanCheckbox id="displayPersonalData" immediate="true" value="#{registerController.showPersonalData}" valueChangeListener="#{registerController.showPersonalData}" onclick="this.form.submit()" />
                        <h:outputLabel styleClass="Float" for="displayPersonalData" value="#{msg.displayPersonalData}" />
                        <h:panelGroup rendered="#{registerController.showPersonalData}" >
                            <h3>#{msg.personalData}</h3>

                            <div class="formblock">
                                <fieldset>
                                    <div>
                                        <h:outputLabel class="Float" for="firstname" value="#{msg.firstName}"/>
                                        <h:inputText label="firstname" value="#{registerController.newPlayer.firstname}" id="firstname">
                                            <f:validateRegex pattern="[A-Za-z]+"/>
                                        </h:inputText>
                                        <h:messages styleClass="error" for="firstname" showDetail="true" showSummary="false"/>
                                    </div>
                                    <div>
                                        <h:outputLabel class="Float" for="lastname" value="#{msg.lastName}" />
                                        <h:inputText label="lastname" value="#{registerController.newPlayer.lastname}" id="lastname">
                                            <f:validateRegex pattern="[A-Za-z]+"/>
                                        </h:inputText>
                                        <h:messages styleClass="error" for="lastname" showDetail="true" showSummary="false"/>
                                    </div>
                                    <div>
                                        <h:outputLabel class="Float" for="dateofbirth" value="#{msg.birthday}" />
                                        <h:inputText label="dateofbirth" value="#{registerController.newPlayer.birthday}" validator="#{registerController.validateBirthday}" id="dateofbirth"/>
                                        <h:messages styleClass="error" for="dateofbirth" showDetail="true" showSummary="false"/>
                                        
                                        
                                    </div>
                                    <div>
                                        <h:outputLabel class="Float" for="gender" value="#{msg.gender}" />
                                        <h:selectOneMenu id="gender" value="#{registerController.newPlayer.gender}">
                                            <f:selectItem itemValue="w" itemLabel="#{msg.female}" />
                                            <f:selectItem itemValue="m" itemLabel="#{msg.male}" />
                                        </h:selectOneMenu>                          

                                    </div>
                                </fieldset>
                            </div>
                        </h:panelGroup>
                        <div id="buttons">
                            <h:commandButton value="#{msg.register}" accesskey="r" action="#{registerController.register}" rendered="#{!registerController.successfulRegistration}"/>
                            <h:panelGroup rendered="#{registerController.successfulRegistration}">
                                <h:outputText value="#{msg.registrationComplete}" />
                                <h:link value="#{msg.login}" outcome="index" />
                            </h:panelGroup>
                        </div>

                        </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
